
/*** START CODE ***/


// Preamble
// ----------------------------
/*
*/
clear all
set more off
set emptycells drop
set seed 20190306

// create empty file to append to. 
gen x = .
tempfile empty
save `empty', replace
clear all

set scheme s1color


// Setup
// ----------------------------
** Set user path globals
	global Dropbox "C:/Dropbox"
	global Archive "C:/Users/emuehleg/Dropbox/EV_ConsumerValuation/JPEM Data Archive"

** Set path globals

// archive folders
global Code		 			"${Archive}/Code"
global Data_Source			"${Archive}/Data"
global ResultsOut			"${Archive}/ResultsOut"
global TabsFigs				"${Archive}/ResultsOut/TabsFigs"

//data subfolders
global Restricted_Data 		"${Data_Source}/Restricted/"
global ElectricityRates		"${Data_Source}/ElectricityRates"
global Boundaries			"${Data_Source}/Boundaries"
global ACS					"${Data_Source}/ACS"
global Data_Clean			"${Data_Source}/Cleaned_Data"

*Data cleaning 
do "${Code}/Data_Electric.do" // cleans utility data from openEI

*Generate Panel Dataset, RD dataset Cleans CBG level data, merges GIS derived data, and cleans Experian data. Merges everything to create final analysis do files
do "${Code}/Data_GIS.do" 
*Output Panel Data: psmatched_panel_EV_utility.dta --> Prepare_Panel_data.do
*Output RD data: EVSales_Panel_Data_distance_matched_CBG.dta --> Prepare_SpatialRD_data.do

***Panel Analysis
*Data Preparation for Panel Data
do "${Code}/Prepare_Panel_data.do"
do "${Code}/Panel_demog.do"
do "${Code}/PanelRegs.do"

***Spatial RD Graphs and Analysis
*Data Preparation for SpatialRD
do "${Code}/Prepare_SpatialRD_data.do"
do "${Code}/SpatialRDgraphs.do"
do "${Code}/RD_discontinuity_graphs.do" 
do "${Code}/SpatialRDregs.do"

*Placebo Tests
do "${Code}/Data_GIS_placebo.do"
do "${Code}/Prepare_SpatialRD_data_placebo.do"
do "${Code}/SpatialRDregs_placebo.do"

***Graphing and Summary Statistics
do "${Code}/summary_statistics_table.do"

*Duration Analysis
*RUN:  DMV_EV_duration.R (cut)
*RUN : Duration_BD.R (cut)
do "${Code}/Experian_lease_extract.do" (NEED TO DETERMINE WHERE DURATION_DATA COMES FROM)
do "${Code}/DMV_duration.do"

***Welfare / Policy Analysis
do "${Code}/Welfare_Policy.do"

/*** END CODE ***/
